﻿
@page "/Wms/BuyReturnOutWarehouseDetail/BatchEdit"
@using nERP.ViewModel.Wms.BuyReturnOutWarehouseDetailVMs
@using System.ComponentModel.DataAnnotations
@inherits BasePage

<ValidateForm @ref="vform" Model="@Model" OnValidSubmit="@Submit">
  <div style="margin-bottom:10px;"> @WtmBlazor.Localizer["Sys.BatchEditConfirm"]</div>
  <Row ItemsPerRow="ItemsPerRow.Two" RowType="RowType.Normal">
    <BootstrapInput @bind-Value="@Model.LinkedVM.Seq"/>
    <Select @bind-Value="@Model.LinkedVM.BuyReturnId" Items="AllBuyReturns" Id="gc85454a5e1f64a5782f01861835aaf41"/>
    <Select @bind-Value="@Model.LinkedVM.BuyReturnOutWarehouseId" Items="AllBuyReturnOutWarehouses" Id="ga24182f0dd6146bbb0a2361075a38e4e"/>
    <Select @bind-Value="@Model.LinkedVM.BuyId" Items="AllBuys" Id="gcfe787eaa20e4a6cb8871333d14d2c33"/>
    <Select @bind-Value="@Model.LinkedVM.BuyDetailId" Items="AllBuyDetails" Id="gc48b514935ce447399f2cf6fe10b7b79"/>
    <Select @bind-Value="@Model.LinkedVM.WarehouseId" Items="AllWarehouses" Id="g716e306dad7544c2b58bf668b74f0862"/>
    <Select @bind-Value="@Model.LinkedVM.GoodsId" Items="AllGoodss" Id="gb65221c2f66e4d33bd66f0c9e466ecae"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.GoodsName"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.GoodsSpec"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.GoodsUnit"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.ReturnNumber"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.Remark"/>
  </Row>

  <div class="modal-footer table-modal-footer">
    <Button ButtonType="ButtonType.Submit" IsAsync="true" Text="@WtmBlazor.Localizer["Sys.Submit"]"/>
    <Button OnClick="OnClose" Text="@WtmBlazor.Localizer["Sys.Close"]"/>
  </div>

</ValidateForm>



@code {
    [Parameter]
    public string id { get; set; }
    [Parameter]
    public string[] ids { get; set; }
    private BuyReturnOutWarehouseDetailBatchVM Model = new BuyReturnOutWarehouseDetailBatchVM();
    private ValidateForm vform { get; set; }
    
    private async Task Submit(EditContext context)
    {
        Model.Ids = ids;
        await PostsForm(vform, "/api/Wms/BuyReturnOutWarehouseDetail/BatchEdit", (s) => WtmBlazor.Localizer["Sys.BatchEditSuccess", s], method: HttpMethodEnum.POST);
    }
            

    public void OnClose()
    {
        CloseDialog();
    }
    
    private List<SelectedItem> AllBuyReturns = new List<SelectedItem>();
    private List<SelectedItem> AllBuyReturnOutWarehouses = new List<SelectedItem>();
    private List<SelectedItem> AllBuys = new List<SelectedItem>();
    private List<SelectedItem> AllBuyDetails = new List<SelectedItem>();
    private List<SelectedItem> AllWarehouses = new List<SelectedItem>();
    private List<SelectedItem> AllGoodss = new List<SelectedItem>();
    protected override async Task OnInitializedAsync()
    {
        
        
        AllBuyReturns = await WtmBlazor.Api.CallItemsApi("/api/Wms/BuyReturnOutWarehouseDetail/GetBuyReturns");
        AllBuyReturns.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllBuyReturnOutWarehouses = await WtmBlazor.Api.CallItemsApi("/api/Wms/BuyReturnOutWarehouseDetail/GetBuyReturnOutWarehouses");
        AllBuyReturnOutWarehouses.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllBuys = await WtmBlazor.Api.CallItemsApi("/api/Wms/BuyReturnOutWarehouseDetail/GetBuys");
        AllBuys.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllBuyDetails = await WtmBlazor.Api.CallItemsApi("/api/Wms/BuyReturnOutWarehouseDetail/GetBuyDetails");
        AllBuyDetails.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllWarehouses = await WtmBlazor.Api.CallItemsApi("/api/Wms/BuyReturnOutWarehouseDetail/GetWarehouses");
        AllWarehouses.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllGoodss = await WtmBlazor.Api.CallItemsApi("/api/Wms/BuyReturnOutWarehouseDetail/GetGoodss");
        AllGoodss.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });

        await base.OnInitializedAsync();
    }
}
